package czy.demo.endpoint;

import org.springframework.boot.actuate.endpoint.annotation.DeleteOperation;
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
import org.springframework.stereotype.Component;

/** web端点 */
@Component
@Endpoint(id="default")
public class DefaultWebEndpoint {

    private String info = "这是一个web端点";

    /* GET方法访问 */
    @ReadOperation()
    public String read(){
        return info;
    }

    /* POST方法访问，参数正常映射 */
    @WriteOperation()
    public String write(String info){
        this.info = info;
        return this.info;
    }

    /* DELETE方法映射 */
    @DeleteOperation()
    public String delete(){
        String i = info;
        this.info = "";
        return i;
    }

}
